<!DOCTYPE html>

<html class="no-js">

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <title></title>
  <meta name="description" content="" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <script src="https://cdn.staticfile.org/axios/0.19.0-beta.1/axios.js"></script>
  <script src="../../cdn/vue/vue.global.min.js"></script>
  <link rel="stylesheet" href="../../cdn/element-plus/index.css" />
  <script src="../../cdn/element-plus/index.full.min.js"></script>

  <link rel="stylesheet" href="../../../lib/index.css" />
  <script src="../../../lib/avue.js"></script>
</head>

<body>
  <div id="app">
    {{obj}}
    <avue-form :option="option" v-model="obj"></avue-form>
  </div>
</body>
<script>
  var app = Vue.createApp({
    data() {
      return {
        obj: {
          table: [0, 2]
        },
        option: {
          column: [
            {
              label: '表格',
              prop: 'table',
              type: 'table',
              multiple: true,
              children: {
                border: true,
                column: [{
                  label: '姓名',
                  width: 120,
                  search: true,
                  prop: 'name'
                }, {
                  label: '性别',
                  prop: 'sex'
                }],
              },
              formatter: (row) => {
                if (Array.isArray(row)) {
                  return row.map(ele => ele.name + '格式化').join(',')
                } else {
                  return row.name + '格式化'
                }
              },
              onLoad: ({ page, value, data }, callback) => {
                console.log(data);
                setTimeout(() => {
                  if (value) {
                    callback([{
                      id: '0',
                      name: '张三',
                      sex: '男'
                    }, {
                      id: '2',
                      name: '王五',
                      sex: '女'
                    }])
                    return
                  }
                  callback({
                    total: 40,
                    data: [{
                      id: '0',
                      name: '张三',
                      sex: '男'
                    }, {
                      id: '1',
                      name: '李四',
                      disabled: true,
                      sex: '女'
                    }, {
                      id: '2',
                      name: '王五',
                      sex: '女'
                    }]
                  })
                }, 1000)
              },
              props: {
                label: 'name',
                value: 'id'
              },
              rules: [
                {
                  required: true,
                  message: '请选择省份',
                  trigger: 'change'
                }
              ]
            }]
        }
      }
    }
  })
  app.use(ElementPlus)
  app.use(AVUE)
  app.mount('#app')
</script>

</html>